// https://www.lintcode.com/problem/largest-number/description
// 自定义的比较函数不能是类的成员函数
bool cmp(const string s1, const string s2) {
    return (s1 + s2) > (s2 + s1);
}
class Solution {
public:
    /**
     * @param nums: A list of non negative integers
     * @return: A string
     */
    string largestNumber(vector<int> &nums) {
        string result = "";
        vector<string> tmp;
        for (int n: nums) tmp.push_back(to_string(n));
        sort(tmp.begin(), tmp.end(), cmp);
        for (string t: tmp) 
        {
            if (result == "" && t == "0") continue;
            result += t;
        }
        if (result == "") return "0";
        return result;
    }
};